package com.jahe.learn.netty4.customcodec;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Long类型数据的编码器
 * @author: jahe.lai
 * @create: 2020-01-09 11:46
 */
public class LongMessageEncoder extends MessageToByteEncoder<Long> {
    private static Logger logger = LoggerFactory.getLogger(LongMessageEncoder.class);
    @Override
    protected void encode(ChannelHandlerContext ctx, Long msg, ByteBuf out) throws Exception {
        logger.warn("--{}", msg);
        out.writeLong(msg);
    }


}
